//
//  VideoController.m
//  TourPlay
//
//  Created by dllo on 15/12/1.
//  Copyright © 2015年 王军岐. All rights reserved.
//

#import "VideoController.h"
#import "VideoTableViewCell.h"

@interface VideoController () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *videoTableV;

@end

@implementation VideoController
- (void)dealloc
{
    [_videoTableV release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"精选视频";
  
    
    self.videoTableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49) style:UITableViewStylePlain];
    self.videoTableV.backgroundColor = [UIColor clearColor];
    self.videoTableV.delegate = self;
    self.videoTableV.dataSource = self;
    [self.videoTableV registerClass:[VideoTableViewCell class] forCellReuseIdentifier:@"cell"];
    // 取消分割线
    self.videoTableV.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.videoTableV];
    [_videoTableV release];
}
- (void)leftAction
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
// 去掉section的悬停
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat sectionHeaderHeight = 30;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    }
    else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return SCREEN_HEIGHT * (1 / 3.f);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellStr = @"cell";
    VideoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];

    
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
#pragma mark - 获取数据
- (void)getUpdate
{
    // 让菊花旋转起来
    MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [hub show:YES];
    hub.labelText = @"努力加载中...";
    
    
    NSString* date = nil;
    NSDateFormatter* formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"YYYYMMdd"];
    date = [formatter stringFromDate:[NSDate date]];
    [formatter release];
    NSLog(@"获取时间:%@", date);
    
    NSString *url = [NSString stringWithFormat:@"http://baobab.wandoujia.com/api/v1/feed?num=5&date=%@&vc=125&u=29724b3d1af7daa52090420444a8c8daa9a330c0", date];
    
    [AppTools getAFNet:url block:^(id result) {
        NSMutableDictionary *bigDic = result;
        //        NSMutableArray *bigArr = [[[bigDic objectForKey:@"dailyList"] firstObject] objectForKey:@"videoList"];
        
        for (NSMutableDictionary *dicTemp in [bigDic objectForKey:@"dailyList"]) {
            
        }
        
//        [self.foundCollectionV reloadData];
        [hub hide:YES];

    } errorBlock:^(NSError *error) {
        [self NetworkError:^{
        }];
        [hub hide:YES];
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
